home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / minix / up1510b.tgz / up1510b / src / commands / kermit / ckuus3.c < prev    next >
C/C++ Source or Header  |  1990-07-19  |  26KB  |  980 lines

  1. /*  C K U U S 3 --  "User Interface" for Unix Kermit, part 3  */
  2.  
  3. /*
  4.  Author: Frank da Cruz (SY.FDC@CU20B),
  5.  Columbia University Center for Computing Activities, January 1985.
  6.  Copyright (C) 1985, Trustees of Columbia University in the City of New York.
  7.  Permission is granted to any individual or institution to use, copy, or
  8.  redistribute this software so long as it is not sold for profit, provided this
  9.  copyright notice is retained. 
  10. */
  11.  
  12. /*  SET and REMOTE commands; screen, debug, interrupt, and logging functions */
  13.  
  14. /* Includes */
  15.  
  16. #include "ckcdeb.h"
  17. #include <stdio.h>
  18. #include <ctype.h>
  19. #include "ckcker.h"
  20. #include "ckucmd.h"
  21. #include "ckuusr.h"
  22. #ifdef UXIII
  23. #include <termio.h>
  24. #endif
  25.  
  26. #ifdef datageneral
  27. extern int con_reads_mt,            /* Flag if console read asynch is active */
  28.            conint_ch,               /* The character read by asynch read */
  29.            conint_avl;              /* Flag that char available */
  30. #endif
  31.  
  32. /* Variables */
  33.  
  34. extern int size, spsiz, rpsiz, urpsiz, npad, timint, rtimo, speed,
  35.   local, server, lpcapr, fmask, cmask, backgrd,
  36.   flow, displa, binary, fncnv, delay, parity, deblog, escape, xargc,
  37.   turn, duplex, cxseen, czseen, nfils, ckxech, pktlog, seslog, tralog, stdouf,
  38.   turnch, bctr, bctu, dfloc, mdmtyp, keep, maxtry,
  39.   rptflg, ebqflg, warn, quiet, cnflg, timef, spsizf, mypadn;
  40.  
  41. extern long filcnt, tlci, tlco, ffc, tfc, fsize;
  42.  
  43. extern char *versio, *protv, *ckxv, *ckzv, *fnsv, *connv, *dftty, *cmdv;
  44. extern char *cmarg, *cmarg2, **xargv, **cmlist;
  45. extern CHAR stchr, mystch, sstate, padch, mypadc, eol, seol, ctlq;
  46. extern CHAR filnam[], ttname[];
  47. char *strcpy();
  48.  
  49. /* Declarations from cmd package */
  50.  
  51. extern char cmdbuf[];            /* Command buffer */
  52.  
  53. /* From main ckuser module... */
  54.  
  55. extern char line[100], *lp;        /* Character buffer for anything */
  56. extern char debfil[50],            /* Debugging log file name */
  57.  pktfil[50],                /* Packet log file name */
  58.  sesfil[50],                /* Session log file name */
  59.  trafil[50];                /* Transaction log file name */
  60.  
  61. extern int tlevel;            /* Take Command file level */
  62. extern FILE *tfile[];            /* Array of take command fd's */
  63.  
  64.  
  65. /* Keyword tables for SET commands */
  66.  
  67.  
  68. /* Block checks */
  69.  
  70. struct keytab blktab[] = {
  71.     "1", 1, 0,
  72.     "2", 2, 0,
  73.     "3", 3, 0
  74. };
  75.  
  76. /* Duplex keyword table */
  77.  
  78. struct keytab dpxtab[] = {
  79.     "full",      0, 0,
  80.     "half",      1, 0
  81. };
  82.  
  83. struct keytab filtab[] = {
  84.     "display", XYFILD, 0,
  85.     "names",   XYFILN, 0,
  86.     "type",    XYFILT, 0,
  87.     "warning", XYFILW, 0
  88. };
  89. int nfilp = (sizeof(filtab) / sizeof(struct keytab));
  90.  
  91. /* Send/Receive Parameters */
  92.  
  93. struct keytab srtab[] = {
  94.     "end-of-packet", XYEOL, 0,
  95.     "packet-length", XYLEN, 0,
  96.     "pad-character", XYPADC, 0,
  97.     "padding", XYNPAD, 0,
  98.     "start-of-packet", XYMARK, 0,
  99.     "timeout", XYTIMO, 0
  100. };
  101. int nsrtab = (sizeof(srtab) / sizeof(struct keytab));
  102.  
  103. /* Flow Control */
  104.  
  105. struct keytab flotab[] = {
  106.     "none",     0, 0,
  107.     "xon/xoff", 1, 0
  108. };
  109. int nflo = (sizeof(flotab) / sizeof(struct keytab));
  110.  
  111. /*  Handshake characters  */
  112.  
  113. struct keytab hshtab[] = {
  114.     "bell", 007, 0,
  115.     "cr",   015, 0,
  116.     "esc",  033, 0,
  117.     "lf",   012, 0,
  118.     "none", 999, 0,            /* (can't use negative numbers) */
  119.     "xoff", 023, 0,
  120.     "xon",  021, 0
  121. };
  122. int nhsh = (sizeof(hshtab) / sizeof(struct keytab));
  123.  
  124. struct keytab fntab[] = {           /* File naming */
  125.     "converted", 1, 0,
  126.     "literal",   0, 0
  127. };
  128.  
  129. struct keytab fttab[] = {        /* File types */
  130.     "binary",    1, 0,
  131.     "text",      0, 0
  132. };
  133.  
  134. extern struct keytab mdmtab[] ;        /* Modem types (in module ckudia.c) */
  135. extern int nmdm;
  136.  
  137. /* Parity keyword table */
  138.  
  139. struct keytab partab[] = {
  140.     "even",    'e', 0,
  141.     "mark",    'm', 0,
  142.     "none",      0, 0,
  143.     "odd",     'o', 0,
  144.     "space",   's', 0
  145. };
  146. int npar = (sizeof(partab) / sizeof(struct keytab));
  147.  
  148.  
  149. /* On/Off table */
  150.  
  151. struct keytab onoff[] = {
  152.     "off",       0, 0,
  153.     "on",        1, 0
  154. };
  155.  
  156. /* Incomplete File Disposition table */
  157.  
  158. struct keytab ifdtab[] = {
  159.     "discard",   0, 0,
  160.     "keep",      1, 0
  161. };
  162.  
  163. /* Terminal parameters table */
  164.  
  165. struct keytab trmtab[] = {
  166.     "bytesize",  0, 0
  167. };
  168.  
  169. /*  D O P R M  --  Set a parameter.  */
  170. /*
  171.  Returns:
  172.   -2: illegal input
  173.   -1: reparse needed
  174.    0: success
  175. */
  176. doprm(xx) int xx; {
  177.     int x, y, z;
  178.     char *s;
  179.  
  180. switch (xx) {
  181.  
  182.  
  183. case XYEOL:    /* These have all been moved to set send/receive... */
  184. case XYLEN:     /* Let the user know what to do. */
  185. case XYMARK:
  186. case XYNPAD:
  187. case XYPADC:
  188. case XYTIMO:
  189.     printf("...Use 'set send' or 'set receive' instead.\n");
  190.     printf("Type 'help set send' or 'help set receive' for more info.\n");
  191.     return(0);
  192.  
  193. case XYIFD:                /* Incomplete file disposition */
  194.     if ((y = cmkey(ifdtab,2,"","discard")) < 0) return(y);
  195.     if ((x = cmcfm()) < 0) return(x);
  196.     keep = y;
  197.     return(0);
  198.  
  199. case XYLINE:
  200.     if ((x = cmtxt("Device name",dftty,&s)) < 0) return(x);
  201.     ttclos();                /* close old line, if any was open */
  202.  
  203.     x = strcmp(s,dftty) ? -1 : dfloc;    /* Maybe let ttopen figure it out... */
  204.     if (ttopen(s,&x,mdmtyp) < 0 ) {     /* Can we open the new line? */
  205.     perror("Sorry, can't open line");
  206.     return(-2);            /* If not, give bad return */
  207.     }
  208.     if (x > -1) local = x;        /* Set local/remote status. */
  209.     strcpy(ttname,s);            /* OK, copy name into real place. */
  210.     if (!local) speed = -1;        /* If remote, say speed unknown. */
  211.     debug(F111,"set line ",ttname,local);
  212.     return(0);
  213.  
  214. case XYCHKT:
  215.     if ((y = cmkey(blktab,3,"","1")) < 0) return(y);
  216.     if ((x = cmcfm()) < 0) return(x);
  217.     bctr = y;
  218.     return(0);
  219.  
  220. case XYDEBU:
  221.     return(seton(&deblog));
  222.  
  223. case XYDELA:
  224.     y = cmnum("Number of seconds before starting to send","5",10,&x);
  225.     debug(F101,"XYDELA: y","",y);
  226.     return(setnum(&delay,x,y,94));
  227.  
  228. case XYDUPL:
  229.     if ((y = cmkey(dpxtab,2,"","full")) < 0) return(y);
  230.     if ((x = cmcfm()) < 0) return(x);
  231.     duplex = y;
  232.     return(0);
  233.  
  234. case XYESC:
  235.     y = cmnum("Decimal ASCII code for escape character","",10,&x);
  236.     return(setcc(&escape,x,y));
  237.  
  238. case XYFILE:
  239.     if ((y = cmkey(filtab,nfilp,"File parameter","")) < 0) return(y);
  240.     switch (y) {
  241.     int z;
  242.     case XYFILD:            /* Display */
  243.         y = seton(&z);
  244.         if (y < 0) return(y);
  245.         quiet = !z;
  246.         return(0);
  247.  
  248.     case XYFILN:            /* Names */
  249.         if ((x = cmkey(fntab,2,"how to handle filenames","converted")) < 0)
  250.             return(x);
  251.         if ((z = cmcfm()) < 0) return(z);
  252.         fncnv = x;
  253.         return(0);
  254.  
  255.     case XYFILT:            /* Type */
  256.         if ((x = cmkey(fttab,2,"type of file","text")) < 0)
  257.             return(x);
  258.         if ((y = cmnum("file byte size (7 or 8)","8",10,&z)) < 0)
  259.             return(y);
  260.         if (z != 7 && z != 8) {
  261.         printf("\n?The choices are 7 and 8\n");
  262.         return(-2);
  263.         }
  264.         if ((y = cmcfm()) < 0) return(y);
  265.         binary = x;
  266.         if (z == 7) fmask = 0177;
  267.           else if (z == 8) fmask = 0377;
  268.         return(0);
  269.  
  270.     case XYFILW:            /* Warning/Write-Protect */
  271.         return(seton(&warn));
  272.  
  273.     default:
  274.         printf("?unexpected file parameter\n");
  275.         return(-2);
  276.     }
  277.  
  278. case XYFLOW:                /* Flow control */
  279.     if ((y = cmkey(flotab,nflo,"","xon/xoff")) < 0) return(y);
  280.     if ((x = cmcfm()) < 0) return(x);
  281.     flow = y;
  282.     return(0);
  283.  
  284. case XYHAND:                /* Handshake */
  285.     if ((y = cmkey(hshtab,nhsh,"","none")) < 0) return(y);
  286.     if ((x = cmcfm()) < 0) return(x);
  287.     turn = (y > 0127) ? 0 : 1 ;
  288.     turnch = y;
  289.     return(0);
  290.  
  291. case XYMODM:
  292. #ifndef MINIX
  293.     if ((x=cmkey(mdmtab,nmdm,"type of modem, direct means none","direct")) < 0)
  294.     return(x);
  295. #endif
  296.     if ((z = cmcfm()) < 0) return(z);
  297.     mdmtyp = x;
  298.     return(0);
  299.     
  300. case XYPARI:                /* Parity */
  301.     if ((y = cmkey(partab,npar,"","none")) < 0) return(y);
  302.     if ((x = cmcfm()) < 0) return(x);
  303.  
  304. /* If parity not none, then we also want 8th-bit prefixing */
  305.  
  306.     if (parity = y) ebqflg = 1; else ebqflg = 0;
  307.     return(0);
  308.  
  309. case XYPROM:
  310.     if ((x = cmtxt("Program's command prompt","C-Kermit>",&s)) < 0) return(x);
  311.     if (*s == '\42') {            /* Quoted string? */
  312.     x = strlen(s) - 1;        /* Yes, strip quotes. */
  313.     if (*(s+x) == '\42')        /* This allows leading or trailing */
  314.         *(s+x) = '\0';        /* blanks. */
  315.         s++;
  316.     }
  317.     cmsetp(s);
  318.     return(0);
  319.  
  320. case XYRETR:                /* Per-packet retry limit */
  321.     y = cmnum("Maximum retries per packet